import java.util.Properties;

class A
{
	public void fun1()
	{
		System.out.println("A---public void fun1");
	}
	public void fun3()
	{
		System.out.println("A---public void fun3");
	}
}

class B extends A
{
	public void fun1()
	{
		System.out.println("B---public void fun1");
	}
	public void fun2()
	{
		System.out.println("B---public void fun2");
	}
}

class C extends A
{
	public void fun1()
	{
		System.out.println("C---public void fun1");
	}
	public void fun2()
	{
		System.out.println("B---public void fun2");
	}
}
class Factory
{
	public static A getInstance(String className)
	{
		A a = null;
		if("B".equals(className))
		{
			a = new B();
		}
		if("C".equals(className))
		{
			a = new C();
		}
		return a;
	}
}

public class TestStr 
{
		
		public static void main(String args[])
		{
			System.getProperties().list(System.out);
			B b = test(new B());
			System.out.println("b is instance of B:"+(b instanceof B));
			System.out.println("b is instance of A:"+(b instanceof A));
			C c = test1(new C());
			b.fun1();
			c.fun1();
			A aa1 = test2(new B());
			System.out.println("aa1 is instance of B:"+(aa1 instanceof B));
			System.out.println("aa1 is instance of A:"+(aa1 instanceof A));
			A aa2 = test2(new C());
			aa1.fun1();
			aa2.fun1();
			System.out.println("----------");
			A aa3 = Factory.getInstance("B");
			aa3.fun1();
			A aa4 = Factory.getInstance("C");
			aa4.fun1();
			String senderAreaCode = "647813";
			System.out.println(senderAreaCode.substring(0, 2).concat("0000") + "," + senderAreaCode.substring(0, 4).concat("00") + "," + senderAreaCode);
			
			sqlValidate(",lzqreceivermobilelzq:lzq13052180503lzq,lzqreceivernamelzq:lzq李先生lzq},lzqdeliveryendtimelzq:lzqlzq,lzqdeliverystarttimelzq:lzq2015-03-20 14:18lzq,lzqfriendidlzq:lzqlzq,lzqspeciallzq:lzq3lzq,lzqweightlzq:lzq5lzq,lzqfreightlzq:lzq44lzq}json");
		}
		public static B test(A a)
		{
			B b = null;
			if (a instanceof B)
			{
			   b = (B)a;
			}
			return b;
		}
		public static C test1(A a)
		{
			C b = null;
			if (a instanceof C)
			{
			   b = (C)a;
			}
			return b;
		}
		public static A test2(A a)
		{
			return a;
		}

		
		
	    protected static boolean sqlValidate(String str) {
	        str = str.toLowerCase();//统一转为小写
	        String badStr = "'|and|exec|execute|insert|select|delete|update|drop|*|%|chr|mid|master|truncate|" +
	                "declare|sitename|net user|xp_cmdshell|create|table|from|grant|group_concat|column_name|" +
	                "information_schema.columns|table_schema|union|where|by|-|--|+|like|//|/|%|#"; //过滤掉的sql关键字，可以手动添加
	        String[] badStrs = badStr.split("\\|");
	        for (int i = 0; i < badStrs.length; i++) {
	            if (str.indexOf(badStrs[i]) >= 0) {
	                return true;
	            }
	        }
	        return false;
	    }
}
